<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import axios from 'axios'

export default  {
  name:  'App',
    metaInfo() {
        return {
            title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
            titleTemplate: title => {
                return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
            }
        }
    },
    mounted(){
      this.checkVerion();
    },
    methods:{
      checkVerion(){
        let matchVer = document.documentElement.getAttribute("version") || localStorage.appVer;
        _.timeout.setGlobal("version",()=>{
          axios.get("/index.html?v="+_.UUID()).then((res)=>{
            let d = res.data;
            let appVer = d.match(/version\=(app\d*)/)[1];
            if(matchVer != appVer){
              localStorage.appVer = appVer;
              window.alert('页面已升级，最新版本' + appVer + '');
              location.reload(true);
            }
          })
        },120000)
      },
    },
}
</script>
